import isWindow from './isWindow';
type Target = HTMLElement | Document | Window;

export default function getClientHeight(target: Target): number {
  let clientHeight = 0;
  if (!target) {
    return clientHeight;
  }
  if (isWindow(target)) {
    clientHeight = (target as Window).innerHeight;
  } else if (target instanceof Document) {
    clientHeight = document.documentElement.clientHeight;
  } else {
    clientHeight = (target as HTMLElement).clientHeight;
  }
  return clientHeight;
}
